﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Controls_Pro_Class : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            pro_ej();
        }
    }
    public void pro_ej()
    {
        DataTable dt = Class1.ExecSel("select top 18 Menu_ID,Menu_Name,Menu_Level,Menu_ParentLevel,Menu_Lock from Class where Menu_Level=2 and Menu_Lock=0 order by Menu_Sort desc");
        dl_ej.DataSource = dt;
        dl_ej.DataKeyField = "Menu_ID";
        dl_ej.DataBind();
        
    }
    protected void dl_ej_DataBinding(object sender, DataListItemEventArgs e)
    {
        Label Label1 = (Label)e.Item.FindControl("Label1");
        Label lblRecordCount = (Label)e.Item.FindControl("lblRecordCount");
        string strSQL = "select top 10 * from Class where Menu_ParentLevel=" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + " and Menu_Lock=0 order by Menu_ID asc";
        IDataReader dr = Class1.GetDataReader(strSQL);
        while (dr.Read())
        {
            Label1.Text += " <a href='wjTrades_sClass_" + dr["Menu_ID"] + ".html' target=_blank>" + dr["Menu_Name"].ToString() + "</a><span class='font_1'></span> |";
        }

        SqlConnection con = Class1.DBconnection();
        string sqlStr = "select * from Product where p_z_ID='" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + "'";
        SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
        DataSet ds = new DataSet();
        da.Fill(ds, "Product");
        string num = ds.Tables["Product"].Rows.Count.ToString();
        lblRecordCount.Text = num;
        da.Dispose();
        ds.Dispose();
        con.Close();
        con.Dispose();
    }
}
